package com.example.fastdfs_demo.controller;

import com.example.fastdfs_demo.service.UploadFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/store")
@Api(value = "FileController|文件操作控制器", description = "文件操作控制器", tags = "file")
public class FileController {

  @Autowired
  private UploadFileService uploadFileService;

  /**
   * 文件上传
   *
   * @return
   * @throws Exception
   */
  @PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data")
  @ApiOperation("文件上传")
  @ApiImplicitParam(name = "files", value = "多个文件，", paramType = "formData", allowMultiple = true, required = true, dataType = "file")
  public String uploadFile(@RequestParam(value = "files", required = true) MultipartFile[] files) throws Exception {
	  return uploadFileService.UploadFilesToServer(files);
  }
  

}
